<template>
  <div><form action="/">
  <van-search
    v-model="value"
    show-action
    placeholder="请输入小区地址"
   
    @cancel="$router.go(-1)"
    input-align="center"
  />
  <van-cell-group >
  <van-cell  v-for="item in list" :key="item.community" @click="chooseCommunity(item)"
   :title="item.communityName" />
 
</van-cell-group>
</form></div>
</template>

<script>
import { getCommunity} from '@/api/house'
export default {
  data() {
    return {
      value: '',
      list:[],
     
    };
  },
  async created(){
    // const res  = await getCommunity(this.$store.state.city.cityName,this.$store.state.city.cityCode)
    //  this.list=res.body
    //  console.log(this.list);
  },
  watch:{
    value:{
        async  handler(newVal){
            const res = await getCommunity(newVal, this.$store.state.city.cityCode)
          console.log(res.body);
          this.list = res.body
          
     
          }
    }
  },
  methods: {
    chooseCommunity(item){
      console.log(item);
      this.$store.commit('city/chooseCommunity',item)
      this.$router.push('/rentHouse')
    }
 
  },
};
</script>

<style scoped lang="less"></style>
